<?php

namespace module\open\validate;

use app\Validate;

class Visitor extends Validate
{
    /**
     * 验证场景.
     *
     * @var array<array<string>>
     */
    protected $scene = [
        'token' => ['account', 'password'],  // 密码登录
    ];
    /**
     * 验证规则.
     *
     * @var array<string>
     */
    protected $rule = [
        'account' => 'require|checkAccount',  // 手机号
        'password'  => 'require|min:6|checkPassword',  // 密码
    ];
    /**
     * 验证字段描述
     * 
     * @var array<string>
     */
    protected $field = [
        'account' => '账号',
        'password' => '密码',
    ];

    // 自定义验证规则
    protected function checkAccount($value, $rule, $data=[])
    {
        return $value === config('http.account') ?: '账号错误';
    }
    // 自定义验证规则
    protected function checkPassword($value, $rule, $data=[])
    {
        return $value === config('http.password') ?: '密码错误';
    }
}